﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.UC.下单MTO;

namespace DXApplicationTangche.UC.订单一览新.销售确认单
{
    public partial class Form待补充定制一览 : DevExpress.XtraEditors.XtraForm
    {
        public Form待补充定制一览()
        {
            InitializeComponent();
            this.查询();
        }
        private void gridView销售一览_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            String saleDate = FunctionHelper.GetbandedgridViewValue(this.bandedGridView销售一览, this.bandedGridView销售一览.FocusedRowHandle, "saleDate");
            String mobile = FunctionHelper.GetbandedgridViewValue(this.bandedGridView销售一览, this.bandedGridView销售一览.FocusedRowHandle, "mobile");
            Double finalPrice = 0.0;
            try
            {
                finalPrice = Convert.ToDouble(FunctionHelper.GetbandedgridViewValue(this.bandedGridView销售一览, this.bandedGridView销售一览.FocusedRowHandle, "finalPrice"));
            }
            catch { }
            new FormMTO销售日记账(saleDate, mobile, finalPrice).ShowDialog();
            this.查询();
        }
        private void bandedGridView销售一览_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            try
            {
                if (e.Column.Name == "gridColumn是否包含未同步套号")
                {
                    if (Convert.ToBoolean(e.CellValue.ToString()))
                    {
                        e.DisplayText = "是";
                        e.Appearance.BackColor = Color.OrangeRed;
                    }
                    else
                    {
                        e.DisplayText = "否";
                        e.Appearance.BackColor = Color.LimeGreen;
                    }
                }
            }
            catch (Exception ex) { }

        }
        private void bandedGridView销售一览_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            try
            {
                if (e.Column.Name == "bandedGridColumn折扣")
                {
                    if (!"0.90".Equals(Math.Round(Convert.ToDecimal(e.DisplayText), 2).ToString())
                        && !"0.95".Equals(Math.Round(Convert.ToDecimal(e.DisplayText), 2).ToString()))
                    {
                        e.DisplayText = null;
                    }
                }
            }
            catch { }
        }

        private void 查询()
        {
            this.gridControl销售一览.DataSource = 销售确认Service.findUnConfirmCustmerMadeOrder();
            this.bandedGridView销售一览.RefreshData();
            this.bandedGridView销售一览.ExpandAllGroups();
        }
    }
}